//main results for educ paper and 2 robustness checks

use "reswappublicver080824.dta"


expand 6
bysort case_id: gen n = _n
tab n, mi


gen qs3 = 8
replace qs3 = m1bs3 if m1bs3 != . & n == 1
replace qs3 = m1as3 if m1as3 != . & n == 1
replace qs3 = m1is3 if m1is3 != . & n == 1
replace qs3 = m1ls3 if m1ls3 != . & n == 1
replace qs3 = m1ns3 if m1ns3 != . & n == 1
replace qs3 = m1ms3 if m1ms3 != . & n == 1
replace qs3 = m1rs3 if m1rs3 != . & n == 1

tab m1bs3 qs3 if n==1, mi
tab m1as3 qs3 if n==1, mi
tab m1is3 qs3 if n==1, mi
tab m1ls3 qs3 if n==1, mi
tab m1ns3 qs3 if n==1, mi
tab m1ms3 qs3 if n==1, mi
tab m1rs3 qs3 if n==1, mi


replace qs3 = m4bs3 if m4bs3 != . & n == 2
replace qs3 = m4as3 if m4as3 != . & n == 2
replace qs3 = m4is3 if m4is3 != . & n == 2
replace qs3 = m4ls3 if m4ls3 != . & n == 2
replace qs3 = m4ns3 if m4ns3 != . & n == 2
replace qs3 = m4ms3 if m4ms3 != . & n == 2
replace qs3 = m4rs3 if m4rs3 != . & n == 2


tab m4bs3 qs3 if n==2, mi
tab m4as3 qs3 if n==2, mi
tab m4is3 qs3 if n==2, mi
tab m4ls3 qs3 if n==2, mi
tab m4ns3 qs3 if n==2, mi
tab m4ms3 qs3 if n==2, mi
tab m4rs3 qs3 if n==2, mi


replace qs3 = m8bs3 if m8bs3 != . & n == 3
replace qs3 = m8as3 if m8as3 != . & n == 3
replace qs3 = m8is3 if m8is3 != . & n == 3
replace qs3 = m8ls3 if m8ls3 != . & n == 3
replace qs3 = m8ns3 if m8ns3 != . & n == 3
replace qs3 = m8ms3 if m8ms3 != . & n == 3
replace qs3 = m8rs3 if m8rs3 != . & n == 3


tab m8bs3 qs3 if n==3, mi
tab m8as3 qs3 if n==3, mi
tab m8is3 qs3 if n==3, mi
tab m8ls3 qs3 if n==3, mi
tab m8ns3 qs3 if n==3, mi
tab m8ms3 qs3 if n==3, mi
tab m8rs3 qs3 if n==3, mi


replace qs3 = w2bs3 if w2bs3 != . & n == 4
replace qs3 = w2as3 if w2as3 != . & n == 4
replace qs3 = w2is3 if w2is3 != . & n == 4
replace qs3 = w2ls3 if w2ls3 != . & n == 4
replace qs3 = w2ns3 if w2ns3 != . & n == 4
replace qs3 = w2ms3 if w2ms3 != . & n == 4
replace qs3 = w2rs3 if w2rs3 != . & n == 4


tab w2bs3 qs3 if n==4, mi
tab w2as3 qs3 if n==4, mi
tab w2is3 qs3 if n==4, mi
tab w2ls3 qs3 if n==4, mi
tab w2ns3 qs3 if n==4, mi
tab w2ms3 qs3 if n==4, mi
tab w2rs3 qs3 if n==4, mi


replace qs3 = w3bs3 if w3bs3 != . & n == 5
replace qs3 = w3as3 if w3as3 != . & n == 5
replace qs3 = w3is3 if w3is3 != . & n == 5
replace qs3 = w3ls3 if w3ls3 != . & n == 5
replace qs3 = w3ns3 if w3ns3 != . & n == 5
replace qs3 = w3ms3 if w3ms3 != . & n == 5
replace qs3 = w3rs3 if w3rs3 != . & n == 5


tab w3bs3 qs3 if n==5, mi
tab w3as3 qs3 if n==5, mi
tab w3is3 qs3 if n==5, mi
tab w3ls3 qs3 if n==5, mi
tab w3ns3 qs3 if n==5, mi
tab w3ms3 qs3 if n==5, mi
tab w3rs3 qs3 if n==5, mi



replace qs3 = w7bs3 if w7bs3 != . & n == 6
replace qs3 = w7as3 if w7as3 != . & n == 6
replace qs3 = w7is3 if w7is3 != . & n == 6
replace qs3 = w7ls3 if w7ls3 != . & n == 6
replace qs3 = w7ns3 if w7ns3 != . & n == 6
replace qs3 = w7ms3 if w7ms3 != . & n == 6
replace qs3 = w7rs3 if w7rs3 != . & n == 6



tab w7bs3 qs3 if n==6, mi
tab w7as3 qs3 if n==6, mi
tab w7is3 qs3 if n==6, mi
tab w7ls3 qs3 if n==6, mi
tab w7ns3 qs3 if n==6, mi
tab w7ms3 qs3 if n==6, mi
tab w7rs3 qs3 if n==6, mi




tab qs3, mi
replace qs3 = . if qs3 == 8
tab qs3, mi




forval i = 1/2 {
gen q`i' = 0
replace q`i' = m1b`i' if m1b`i' != . & n == 1
replace q`i' = m1a`i' if m1a`i' != . & n == 1
replace q`i' = m1i`i' if m1i`i' != . & n == 1
replace q`i' = m1l`i' if m1l`i' != . & n == 1
replace q`i' = m1n`i' if m1n`i' != . & n == 1
replace q`i' = m1m`i' if m1m`i' != . & n == 1
replace q`i' = m1r`i' if m1r`i' != . & n == 1

tab m1b`i' q`i' if n==1, mi
tab m1a`i' q`i' if n==1, mi
tab m1i`i' q`i' if n==1, mi
tab m1l`i' q`i' if n==1, mi
tab m1n`i' q`i' if n==1, mi
tab m1m`i' q`i' if n==1, mi
tab m1r`i' q`i' if n==1, mi

replace q`i' = m4b`i' if m4b`i' != . & n == 2
replace q`i' = m4a`i' if m4a`i' != . & n == 2
replace q`i' = m4i`i' if m4i`i' != . & n == 2
replace q`i' = m4l`i' if m4l`i' != . & n == 2
replace q`i' = m4n`i' if m4n`i' != . & n == 2
replace q`i' = m4m`i' if m4m`i' != . & n == 2
replace q`i' = m4r`i' if m4r`i' != . & n == 2

tab m4b`i' q`i' if n==2, mi
tab m4a`i' q`i' if n==2, mi
tab m4i`i' q`i' if n==2, mi
tab m4l`i' q`i' if n==2, mi
tab m4n`i' q`i' if n==2, mi
tab m4m`i' q`i' if n==2, mi
tab m4r`i' q`i' if n==2, mi

replace q`i' = m8b`i' if m8b`i' != . & n == 3
replace q`i' = m8a`i' if m8a`i' != . & n == 3
replace q`i' = m8i`i' if m8i`i' != . & n == 3
replace q`i' = m8l`i' if m8l`i' != . & n == 3
replace q`i' = m8n`i' if m8n`i' != . & n == 3
replace q`i' = m8m`i' if m8m`i' != . & n == 3
replace q`i' = m8r`i' if m8r`i' != . & n == 3

tab m8b`i' q`i' if n==3, mi
tab m8a`i' q`i' if n==3, mi
tab m8i`i' q`i' if n==3, mi
tab m8l`i' q`i' if n==3, mi
tab m8n`i' q`i' if n==3, mi
tab m8m`i' q`i' if n==3, mi
tab m8r`i' q`i' if n==3, mi


replace q`i' = w2b`i' if w2b`i' != . & n == 4
replace q`i' = w2a`i' if w2a`i' != . & n == 4
replace q`i' = w2i`i' if w2i`i' != . & n == 4
replace q`i' = w2l`i' if w2l`i' != . & n == 4
replace q`i' = w2n`i' if w2n`i' != . & n == 4
replace q`i' = w2m`i' if w2m`i' != . & n == 4
replace q`i' = w2r`i' if w2r`i' != . & n == 4

tab w2b`i' q`i' if n==4, mi
tab w2a`i' q`i' if n==4, mi
tab w2i`i' q`i' if n==4, mi
tab w2l`i' q`i' if n==4, mi
tab w2n`i' q`i' if n==4, mi
tab w2m`i' q`i' if n==4, mi
tab w2r`i' q`i' if n==4, mi


replace q`i' = w3b`i' if w3b`i' != . & n == 5
replace q`i' = w3a`i' if w3a`i' != . & n == 5
replace q`i' = w3i`i' if w3i`i' != . & n == 5
replace q`i' = w3l`i' if w3l`i' != . & n == 5
replace q`i' = w3n`i' if w3n`i' != . & n == 5
replace q`i' = w3m`i' if w3m`i' != . & n == 5
replace q`i' = w3r`i' if w3r`i' != . & n == 5

tab w3b`i' q`i' if n==5, mi
tab w3a`i' q`i' if n==5, mi
tab w3i`i' q`i' if n==5, mi
tab w3l`i' q`i' if n==5, mi
tab w3n`i' q`i' if n==5, mi
tab w3m`i' q`i' if n==5, mi
tab w3r`i' q`i' if n==5, mi


replace q`i' = w7b`i' if w7b`i' != . & n == 6
replace q`i' = w7a`i' if w7a`i' != . & n == 6
replace q`i' = w7i`i' if w7i`i' != . & n == 6
replace q`i' = w7l`i' if w7l`i' != . & n == 6
replace q`i' = w7n`i' if w7n`i' != . & n == 6
replace q`i' = w7m`i' if w7m`i' != . & n == 6
replace q`i' = w7r`i' if w7r`i' != . & n == 6

tab w7b`i' q`i' if n==6, mi
tab w7a`i' q`i' if n==6, mi
tab w7i`i' q`i' if n==6, mi
tab w7l`i' q`i' if n==6, mi
tab w7n`i' q`i' if n==6, mi
tab w7m`i' q`i' if n==6, mi
tab w7r`i' q`i' if n==6, mi


tab q`i', mi
replace q`i' = . if (q`i' == 0 | q`i' == 6)
tab q`i', mi
}



gen bl = 0
replace bl = 1 if (m1b1 != . | m1b2 != . | m1b3 != . | m1b4 != . | m1b5 != .) & n == 1
replace bl = 1 if (m4b1 != . | m4b2 != . | m4b3 != . | m4b4 != . | m4b5 != .) & n == 2
replace bl = 1 if (m8b1 != . | m8b2 != . | m8b3 != . | m8b4 != . | m8b5 != .) & n == 3
replace bl = 1 if (w2b1 != . | w2b2 != . | w2b3 != . | w2b4 != . | w2b5 != .) & n == 4
replace bl = 1 if (w3b1 != . | w3b2 != . | w3b3 != . | w3b4 != . | w3b5 != .) & n == 5
replace bl = 1 if (w7b1 != . | w7b2 != . | w7b3 != . | w7b4 != . | w7b5 != .) & n == 6
tab bl, mi


gen asian = 0
replace asian = 1 if (m1a1 != . | m1a2 != . | m1a3 != . | m1a4 != . | m1a5 != .) & n == 1
replace asian = 1 if (m4a1 != . | m4a2 != . | m4a3 != . | m4a4 != . | m4a5 != .) & n == 2
replace asian = 1 if (m8a1 != . | m8a2 != . | m8a3 != . | m8a4 != . | m8a5 != .) & n == 3
replace asian = 1 if (w2a1 != . | w2a2 != . | w2a3 != . | w2a4 != . | w2a5 != .) & n == 4
replace asian = 1 if (w3a1 != . | w3a2 != . | w3a3 != . | w3a4 != . | w3a5 != .) & n == 5
replace asian = 1 if (w7a1 != . | w7a2 != . | w7a3 != . | w7a4 != . | w7a5 != .) & n == 6


gen ind = 0
replace ind = 1 if (m1i1 != . | m1i2 != . | m1i3 != . | m1i4 != . | m1i5 != .) & n == 1
replace ind = 1 if (m4i1 != . | m4i2 != . | m4i3 != . | m4i4 != . | m4i5 != .) & n == 2
replace ind = 1 if (m8i1 != . | m8i2 != . | m8i3 != . | m8i4 != . | m8i5 != .) & n == 3
replace ind = 1 if (w2i1 != . | w2i2 != . | w2i3 != . | w2i4 != . | w2i5 != .) & n == 4
replace ind = 1 if (w3i1 != . | w3i2 != . | w3i3 != . | w3i4 != . | w3i5 != .) & n == 5
replace ind = 1 if (w7i1 != . | w7i2 != . | w7i3 != . | w7i4 != . | w7i5 != .) & n == 6

gen lat = 0
replace lat = 1 if (m1l1 != . | m1l2 != . | m1l3 != . | m1l4 != . | m1l5 != .) & n == 1
replace lat = 1 if (m4l1 != . | m4l2 != . | m4l3 != . | m4l4 != . | m4l5 != .) & n == 2
replace lat = 1 if (m8l1 != . | m8l2 != . | m8l3 != . | m8l4 != . | m8l5 != .) & n == 3
replace lat = 1 if (w2l1 != . | w2l2 != . | w2l3 != . | w2l4 != . | w2l5 != .) & n == 4
replace lat = 1 if (w3l1 != . | w3l2 != . | w3l3 != . | w3l4 != . | w3l5 != .) & n == 5
replace lat = 1 if (w7l1 != . | w7l2 != . | w7l3 != . | w7l4 != . | w7l5 != .) & n == 6

gen nat = 0
replace nat = 1 if (m1n1 != . | m1n2 != . | m1n3 != . | m1n4 != . | m1n5 != .) & n == 1
replace nat = 1 if (m4n1 != . | m4n2 != . | m4n3 != . | m4n4 != . | m4n5 != .) & n == 2
replace nat = 1 if (m8n1 != . | m8n2 != . | m8n3 != . | m8n4 != . | m8n5 != .) & n == 3
replace nat = 1 if (w2n1 != . | w2n2 != . | w2n3 != . | w2n4 != . | w2n5 != .) & n == 4
replace nat = 1 if (w3n1 != . | w3n2 != . | w3n3 != . | w3n4 != . | w3n5 != .) & n == 5
replace nat = 1 if (w7n1 != . | w7n2 != . | w7n3 != . | w7n4 != . | w7n5 != .) & n == 6

gen mena = 0
replace mena = 1 if (m1m1 != . | m1m2 != . | m1m3 != . | m1m4 != . | m1m5 != .) & n == 1
replace mena = 1 if (m4m1 != . | m4m2 != . | m4m3 != . | m4m4 != . | m4m5 != .) & n == 2
replace mena = 1 if (m8m1 != . | m8m2 != . | m8m3 != . | m8m4 != . | m8m5 != .) & n == 3
replace mena = 1 if (w2m1 != . | w2m2 != . | w2m3 != . | w2m4 != . | w2m5 != .) & n == 4
replace mena = 1 if (w3m1 != . | w3m2 != . | w3m3 != . | w3m4 != . | w3m5 != .) & n == 5
replace mena = 1 if (w7m1 != . | w7m2 != . | w7m3 != . | w7m4 != . | w7m5 != .) & n == 6

gen multi = 0
replace multi = 1 if (m1r1 != . | m1r2 != . | m1r3 != . | m1r4 != . | m1r5 != .) & n == 1
replace multi = 1 if (m4r1 != . | m4r2 != . | m4r3 != . | m4r4 != . | m4r5 != .) & n == 2
replace multi = 1 if (m8r1 != . | m8r2 != . | m8r3 != . | m8r4 != . | m8r5 != .) & n == 3
replace multi = 1 if (w2r1 != . | w2r2 != . | w2r3 != . | w2r4 != . | w2r5 != .) & n == 4
replace multi = 1 if (w3r1 != . | w3r2 != . | w3r3 != . | w3r4 != . | w3r5 != .) & n == 5
replace multi = 1 if (w7r1 != . | w7r2 != . | w7r3 != . | w7r4 != . | w7r5 != .) & n == 6

gen all2 = 0 if mena == 1
replace all2 = 1 if bl == 1
replace all2 = 2 if asian == 1	
replace all2 = 3 if ind == 1		
replace all2 = 4 if lat == 1	
replace all2 = 5 if nat == 1		
replace all2 = 6 if multi == 1
tab all2, mi	

gen mn = .
replace mn = 0 if n == 1
replace mn = 1 if n == 2
replace mn = 2 if n == 3

tab n mn, mi

gen wn = .
replace wn = 0 if n == 4
replace wn = 1 if n == 5
replace wn = 2 if n == 6

tab n wn, mi


gen treatb = all2
replace treatb = 0 if all2 == 0  
replace treatb = 0 if all2 >= 2  & all2 != .
tab treatb all2, mi

*main results

metobit qs3 ib1.all2 i.red i.mn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b1

metobit qs3 ib1.all2##red i.mn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b2

metobit qs3 ib1.all2 i.red i.wn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b3

metobit qs3 ib1.all2##red i.wn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b4

metobit qs3 treatb i.red i.mn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b5

metobit qs3 treatb##red i.mn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b6

metobit qs3 treatb i.red i.wn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b7

metobit qs3 treatb##red i.wn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b8

esttab b1 b2 b3 b4 b5 b6 b7 b8 ///
using "reswapeducmain080824.csv", se pr2 star(+ 0.1 * 0.05 ** 0.01 *** 0.001) replace

*graph
metobit qs3 treatb##red i.wn  || case_id:, vce(cluster case_id) ll(1) ul(5)	
margins treatb#red, at(wn=0) post coeflegend 
marginsplot, xdimension(treatb) noci ///
	xlabel(0 "non-Black in Profile" 1 "Black in Profile") ///
	xtitle(" ") ytitle(" ") ///
	title("Predicted Behavioral Intent Rating of Women's Profiles" "- By Respondent's Educational Level") 
graph export reeduc080824.pdf, replace


local full i.ng year i.nr i.rpeduc pnati demo dateb netb blacknlperr ib1.nb ib2.nregion

metobit qs3 ib1.all2 i.red `full' i.mn if reasonchecked == 0 || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b1

metobit qs3 ib1.all2##red `full' i.mn if reasonchecked == 0 || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b2

metobit qs3 ib1.all2 i.red `full' i.wn if reasonchecked == 0 || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b3

metobit qs3 ib1.all2##red `full' i.wn if reasonchecked == 0 || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b4

metobit qs3 treatb i.red `full' i.mn if reasonchecked == 0 || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b5

metobit qs3 treatb##red `full' i.mn if reasonchecked == 0 || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b6

metobit qs3 treatb i.red `full' i.wn if reasonchecked == 0 || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b7

metobit qs3 treatb##red `full' i.wn if reasonchecked == 0 || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b8

esttab b1 b2 b3 b4 b5 b6 b7 b8 ///
using "reswapeducrestricted080824.csv", se pr2 star(+ 0.1 * 0.05 ** 0.01 *** 0.001) replace


*most attentive
keep if (howmany == 4 | howmany == 3)

metobit qs3 ib1.all2 i.red i.mn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b1

metobit qs3 ib1.all2##red i.mn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b2

metobit qs3 ib1.all2 i.red i.wn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b3

metobit qs3 ib1.all2##red i.wn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b4

metobit qs3 treatb i.red i.mn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b5

metobit qs3 treatb##red i.mn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b6

metobit qs3 treatb i.red i.wn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b7

metobit qs3 treatb##red i.wn || case_id:, vce(cluster case_id) ll(1) ul(5)
est sto b8

esttab b1 b2 b3 b4 b5 b6 b7 b8 ///
using "reswapeducSCREENERS080824.csv", se pr2 star(+ 0.1 * 0.05 ** 0.01 *** 0.001) replace


clear
